<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
    }

    html,
    body {
      height: 100%;
      background-color: chartreuse;
    }

    .box {
      scale: 0.5;
      margin: auto;
      display: flex;
      padding: 16px;
      flex-wrap: wrap;
      width: 70vw;
      height: 50vh;
      background-color: antiquewhite;

    }

    .target,
    .target2 {
      width: 100px;
      height: 100px;
      background-color: red;
      margin-right: 8px;
    }

    .selected {
      background-color: blueviolet
    }
  </style>
</head>


<body>

  <div>

  </div>
  <div class="box">

    <div class="target"></div>
    <div class="target"></div>
    <div class="target"></div>
    <div class="target2"></div>
  </div>


  <script src="//daybrush.com/selecto/release/latest/dist/selecto.min.js"></script>
  <script>


    const selecto = new Selecto({
      className: 'test',
      // The container to add a selection element
      dragContainer: document.querySelector('.box'),
      // container: document.querySelector('.box'),
      rootContainer: document.body,
      // Selecto's root container (No transformed container. (default: null)
      // Targets to select. You can register a queryselector or an Element.

      selectableTargets: [".target", document.querySelector(".target2")],
      hitRate: 20,
      selectByClick: true,
      selectFromInside: true,
      ratio: 0,
      toggleContinueSelect: ["shift"],

    });

    selecto.on("select", e => {
      console.log('==e====>', e)
      e.added.forEach(el => {
        el.classList.add("selected");
      });
      e.removed.forEach(el => {
        el.classList.remove("selected");
      });
    });
  </script>
</body>

</html>